<template>
	<view class="content">
		
		<u-form-item label-width="150" label="姓名"><u-input disabled v-model="user.realname" placeholder="请输入您的姓名" /></u-form-item>
		<u-form-item  label-width="150" label="年级"><u-input disabled v-model="user.grade" placeholder="请输入您的年级" /></u-form-item>
		<u-form-item  label-width="150" label="班级"><u-input disabled v-model="user.class"  placeholder="请输入您的班级"/></u-form-item>
		<u-form-item  label-width="150" label="手机"><u-input type="number" v-model="user.mobile"  placeholder="请输入您的手机号码"/></u-form-item>
		
	    <u-form-item  label-width="150" label="单位名称"><u-input v-model="user.company"  placeholder="请输入您的单位名称"/></u-form-item>
	    <u-form-item  label-width="150" label="职务"><u-input v-model="user.position"  placeholder="请输入您的职务"/></u-form-item>
	
	  <u-button type="error" throttle-time="500" :loading="loading" @click="save" style="margin-top: 20px;">保存</u-button>
	 <auth :isauth="check_auth"></auth>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user:{},
				obj:{},
				loading:false
			}
		},
		onLoad:function(){
			console.log(11111)
			this.user=uni.getStorageSync("user")
			console.log(this.user)
		},
		methods:{
			
			save(){
				
				
				if (!this.$u.test.mobile(this.user.mobile)) {
					 this.msg("手机格式不正确")
					return
				}
				if (this.user.company=="" ){
					 this.msg("公司名称不能为空")
					 return
				}  
				if (this.user.position=="" || this.user.position == null){
					 this.msg("职位不能为空")
					 return
				}
				this.loading=true
				this.$u.post('index.php?class=user&act=updateinfo', {
                    id:uni.getStorageSync("uid"),
					mobile:this.user.mobile,
					company:this.user.company,
					position:this.user.position,
					
				}).then(res => {
					this.loading=false
				    if (res.code==0){
						  uni.setStorageSync("user",res.data)
						 
						  this.msg("更改成功")
					}else{
						this.msg(res.msg)
					}
					
				});
			}
		}
	}
</script>

<style>
</style>
